﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;//引入命名空间
using Tank.Properties;//
using System.Windows.Forms;//

namespace Tank
{
    /// <summary>
    /// 玩家A
    /// </summary>
    public class P1Tank : Player
    {
        #region 玩家ATank图片

        /// <summary>
        /// 玩家1Tank图片
        /// </summary>
        public static Image[] TankImg = new Image[]{
                 Resources.p1U,
                 Resources.p1D,
                 Resources.p1L,
                 Resources.p1R
            };

        #endregion

        #region 构造函数
        /// <summary>
        /// 构造函数（无参）
        /// </summary>
        public P1Tank()
        {
        }

        /// <summary>
        /// 构造函数（带参）
        /// </summary>
        /// <param name="x">Tank所处的X坐标</param>
        /// <param name="y">Tank所处的Y坐标</param>
        /// <param name="life">Tank的生命</param>
        /// <param name="sp">Tank的速度</param>
        /// <param name="dir">Tank的方向</param>
        /// <param name="dir">Tank的图片</param>
        public P1Tank(int x, int y, int life, int sp, Direction dir)
            : base(x, y, TankImg[0].Width, TankImg[0].Height, life, sp, dir, TankImg)
        {
            this.Ap = 50;
            this.Dp = 15;
        }
        #endregion

        #region 移动、绘制

        /// <summary>
        /// 按下移动键W/S/A/D
        /// </summary>
        /// <param name="e"></param>
        public override void KeyDonw(KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.W:
                    DirU = true;
                    break;
                case Keys.S:
                    DirD = true;
                    break;
                case Keys.A:
                    DirL = true;
                    break;
                case Keys.D:
                    DirR = true;
                    break;
                case Keys.K:
                    Fire();
                    break;
                default:
                    break;
            }
            
            if (e.KeyCode == Keys.W | e.KeyCode == Keys.S | e.KeyCode == Keys.A | e.KeyCode == Keys.D)
            {
                base.Move();
            }
        }

        /// <summary>
        /// 释放移动键W/S/A/D
        /// </summary>
        /// <param name="e"></param>
        public override void KeyUp(KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
                case Keys.W:
                    DirU = false;
                    break;
                case Keys.S:
                    DirD = false;
                    break;
                case Keys.A:
                    DirL = false;
                    break;
                case Keys.D:
                    DirR = false;
                    break;
                default:
                    break;
            }
            base.AdjustDir();       
        }

        #endregion

    }
}
